package com.wuhan.template.module.zixun.adapter;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.wuhan.template.base.BaseFragment;
import com.wuhan.template.module.zixun.fragment.ZixunCommonFragment;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2016/5/16.
 */
public class ZixunFragPagerAdapter extends FragmentStatePagerAdapter {


    private String[] titles = {"头条", "武汉", "活动", "原创", "见微", "教育", "问政"
            , "热点", "图片", "广电"};
    private Map<String, String> params = new HashMap<>();


    public ZixunFragPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {

        //ZixunCommonFragment fragment = new ZixunCommonFragment();
        //Bundle bundel = new Bundle();
        //bundel.putString("position", "" + position);
        //fragment.setArguments(bundel);
        //return BaseFragment.newInstance(ZixunCommonFragment.class, params);

        params.put("position", "" + position);
        ZixunCommonFragment fragment =
                BaseFragment.newInstance(ZixunCommonFragment.class, params);
        return fragment;
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return titles[position];
    }

    @Override
    public int getCount() {
        return titles.length;
    }
}
